/*
 * AuthorCategoryDict.h
 *
 *  Created on: Sep 20, 2011
 *      Author: srihari
 */

#ifndef AUTHORCATEGORYDICT_H_
#define AUTHORCATEGORYDICT_H_

#include "../include/includes.h"
#include "../include/config.h"
#include "../include/CUtilities.h"
using namespace std;

class AuthorCategoryDict {
public:
	static AuthorCategoryDict* instance;
	map<string, size_t> authorMap;
	map<string, size_t> categoryMap;
	map<size_t, string> authorTOFileMap;
	map<size_t, string> linkDictMap;
	size_t nextAuthId;
	size_t nextCatId;
	string dirPath;
	ofstream authorStream;
	ofstream categoryStream;
	ofstream linkStream;
	AuthorCategoryDict();
	virtual ~AuthorCategoryDict();

	size_t addAuthor(string author);
	size_t addCategory(string category);
	void insertAuthorToFileMap(size_t aid, size_t fid);
	string getAuthorByFileID(size_t fid);
	void addLinkPair(string source,string destination);
	static AuthorCategoryDict* getInstance();
	void writeToDisk();
	void constructLinkDict(std::map<string, size_t>);
	void insertIntoLinkDict(size_t, size_t);
};

#endif /* AUTHORCATEGORYDICT_H_ */
